#include "modifyitemdlg.h"
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>

ModifyItemDlg::ModifyItemDlg(QWidget *parent) :
    QDialog(parent)
{
//    this->setWindowFlags(Qt::Tool);
    this->resize(210, 195);
    this->setWindowTitle("修改：");

    QGridLayout *gLayout = new QGridLayout;
    gLayout->addWidget(new QLabel("减免："));
    gLayout->addWidget(&lineEditDiscount);
    gLayout->addWidget(new QLabel("数量："));
    gLayout->addWidget(&lineEditCount);
    gLayout->addWidget(new QLabel("备注："));
    gLayout->addWidget(&lineEditNotes);
    QDialogButtonBox *btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
    gLayout->addWidget(btnBox);
    this->setLayout(gLayout);

    connect(btnBox, &QDialogButtonBox::accepted, this, &ModifyItemDlg::accept);
    connect(btnBox, &QDialogButtonBox::rejected, this, &ModifyItemDlg::reject);
}

float ModifyItemDlg::getDicount()
{
    return lineEditDiscount.text().toFloat();
}

void ModifyItemDlg::setDicount(float d)
{
    lineEditDiscount.setText(QString::number(d));
}

int ModifyItemDlg::getCount()
{
    return lineEditCount.text().toInt();
}

void ModifyItemDlg::setCount(int c)
{
    lineEditCount.setText(QString::number(c));
}

QString ModifyItemDlg::getNotes()
{
    return lineEditNotes.text();
}

void ModifyItemDlg::setNotes(const QString &s)
{
    lineEditNotes.setText(s);
}
